package com.htrq.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.htrq.entity.ICKJhx;
import com.htrq.entity.Page;
import com.htrq.service.ICardjhService;
import com.htrq.util.ExportToExcelUtil;

@Controller
@RequestMapping("jsp/basinfo")
public class ICardjhController {
	
	@Resource
	private ICardjhService jhService;
	
	@RequestMapping("getAllkjh")
	public String getAllizc(ICKJhx jh, Page page, HttpServletResponse response) throws IOException, ParseException {
		List<ICKJhx> list=jhService.getAllkjh(jh,page);
		String str=JSON.toJSONString(list);
		Long total=jhService.getTotal(jh);
		String json="{total:"+total+",jhs:"+str+"}";
		response.setContentType("text/html;charset=utf8");
		PrintWriter out =response.getWriter();
		out.write(json);
		return null;
	}
	
	@RequestMapping("exportjh")
	public String exportjh(ICKJhx jhx,HttpServletRequest request,HttpServletResponse response) throws Exception{
		String titles[]={"灰卡卡号","解灰前金额","解灰后金额","解灰时间","班次","发卡站点","解灰站点","解灰类别","操作员"};
		List<Object[]> list=jhService.exportbyForm(jhx);
		ExportToExcelUtil.exportToExcel(request,response,"卡解灰查询导出结果.xls", "记录", titles, list);
		return null;
	}
}
